package qst.com.bacK.mapper;

import org.apache.ibatis.annotations.*;
import qst.com.bacK.pojo.entity.Team;
import qst.com.bacK.pojo.entity.TestPersonnel;

import java.sql.SQLException;
import java.util.List;

/**
 * Author:   msh
 * Date:     2024/10/12 上午10:01
 * Description:
 */
public interface ClassTeamMapper {
    @Select("select * from testpersonnel where team_id = #{id}")
    List<TestPersonnel> findByTeam(int id) throws SQLException;

    @Delete("delete from class_teams where id = #{id}")
    void delete(int id) throws SQLException;

    @Select("select * from class_teams where id = #{id}")
    Team findById(Integer id) throws SQLException;

    @Select("select * from class_teams")
    List<Team> findAll() throws SQLException;

    @Select("select id,name,begin_year,status,creator_id from class_teams where creator_id = #{id}")
    List<Team> findByCreator(Integer id) throws SQLException;

    @Insert("insert into class_teams(name,begin_year,status,creator_id) values(#{name},#{beginYear},#{status},#{creatorId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int save(Team t) throws SQLException;

    @Update("update class_teams set name = #{name},begin_year = #{beginYear},status = #{status} where id = #{id}")
    void update(Team t) throws SQLException;
}
